package demo2;

public class StaticProxy {
    public static void main(String[] args) {
        You you = new You();
        new WeddingCompany(new You()).happyMarry();
        new Thread( ()-> System.out.println("代理对象") ).start();
    }

}
interface Marry{
    void happyMarry();
}
class You implements Marry{

    @Override
    public void happyMarry() {
        System.out.println("你要结婚了，开心");
    }
}
class WeddingCompany implements Marry{
    private You target;

    public WeddingCompany(You target) {
        this.target = target;
    }

    @Override
    public void happyMarry() {
        before();
        target.happyMarry();
        after();
    }

    private void after() {
        System.out.println("结婚后。。");
    }

    private void before() {
        System.out.println("结婚前。。");
    }
}